package cn.lysj.framework.elm.controller;

import cn.lysj.framework.base.BaseController;
import cn.lysj.framework.common.annotation.CurrentUser;
import cn.lysj.framework.common.domain.User;
import cn.lysj.framework.common.utils.pagination.PageUtil;
import cn.lysj.framework.common.utils.pagination.PageVo;
import cn.lysj.framework.common.utils.web.ParamUtil;
import cn.lysj.framework.common.utils.web.Resp;
import cn.lysj.framework.elm.domain.ElmFoodDetail;
import cn.lysj.framework.elm.domain.ElmOrder;
import cn.lysj.framework.elm.elmenum.ElmOrderStatus;
import cn.lysj.framework.elm.repository.ElmFoodDetailRepository;
import cn.lysj.framework.elm.service.ElmOrderService;
import eleme.openapi.sdk.api.exception.ServiceException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author drj
 * @description 饿了么订单控制层
 * @create 2019-01-21 16:35:47
 **/
@Slf4j
@RestController
@Api(description = "饿了么订单管理接口")
@RequestMapping("/elm_order")
public class ElmOrderController extends BaseController<ElmOrder> {

    @Resource
    private ElmOrderService elmOrderService;

    @Override
    public ElmOrderService getService() {
        return elmOrderService;
    }


    @GetMapping("/list_rewrite")
    public Resp list(@CurrentUser User user, ElmOrder elmOrder, PageVo pageVo) {
        elmOrder.setStoreId(user.getStoreId());
        return new Resp(elmOrderService.list(elmOrder, pageVo));
    }

    /*
     * @author drj
     * @date 2019-01-22 15:20
     * @Description :饿了么手动接单
     */
    @PostMapping("/manual_order")
    public Resp manualOrder(String elmOrderId) {
        return elmOrderService.manualOrder(elmOrderId);
    }

    /*
     * @author drj
     * @date 2019-01-23 14:40
     * @Description :同意退款
     */
    @PostMapping("/agree_refund")
    public Resp agreeRefund(String elmOrderId) {
        return elmOrderService.agreeRefund(elmOrderId);
    }

    /*
     * @author drj
     * @date 2019-01-23 14:41
     * @Description :拒绝退款
     */
    @PostMapping("/dis_agree_refund")
    public Resp disagreeRefund(String elmOrderId) {
        return elmOrderService.disagreeRefund(elmOrderId);
    }
}
